export default class system{
  constructor(){
    this.info = wx.getSystemInfoSync()
    this.none = {
      success : function(){},
      fail:function(){},
      complete:function(){}
    }
    //console.log(this.info)
  }
  load(){
    wx.onMemoryWarning(this.onMemoryWarning.bind(this))
    wx.onAudioInterruptionBegin(this.lostFocus.bind(this))
    wx.onAudioInterruptionEnd(this.gotFocus.bind(this))
    wx.exitMiniProgram({
      sucess: function () { },
      fail: function () { },
      complete: this.quit.bind(this)
    })
    wx.onShow(this.onShow.bind(this))
    wx.onHide(this.onHide.bind(this))
    wx.onWindowResize(this.onResize.bind(this))
  }
  lostFocus(){}
  gotFocus(){}
  lowMemory(){}
  quit(){}
  onShow(){}
  onHide(){}
  onResize(){}
  getLanchArg(){
    return wx.getlanchOptionsSync()
  }
  getClipboardData(cond){
    wx.getClipboardData({
      success: cond.success,
      fail: cond.fail,
      complete: cond.complete
    })
  }
  setClipboardData(cond){
    wx.setClipboardData({
      data: cond.data,
      success: cond.success,
      fail: cond.fail,
      complete: cond.complete
    })
  }
  onMemoryWarning(){}
  setScreenBrightness(cond){
    wx.getScreenBrightness({
      success: cond.success,
      fail: cond.fail,
      complete: cond.complete,
    })
  }
  getScreenBrightness(cond) {
    wx.setScreenBrightness({
      success: cond.success,
      fail: cond.fail,
      complete: cond.complete,
    })
  }
  setKeepScreenOn(toggle,cond){
    wx.setKeepScreenOn({
      keepScreenOn: toggle,
      success: cond.success,
      fail: cond.fail,
      complete: cond.complete,
    })
  }
  
  vibrate(type,cond = {}){
    if (type == "long"){
      wx.vibrateLong({
        success: cond.success,
        fail: cond.fail,
        complete: cond.complete,
      })
    }else{
      wx.vibrateShort({
        success: cond.success,
        fail: cond.fail,
        complete: cond.complete,
      })
    }
  }

  showMessage(obj){
    obj.title = obj.title || "unknown"
    obj.icon = obj.icon || "none" //success loading none
    obj.duration = obj.duration || 3000
    obj.mask = obj.mask || true
    //sucess fail complete
    return wx.showToast(obj)
  }
  hideMessage(){
    return wx.hideToast()
  }
  showLoading(obj){
    return wx.showLoading(obj)
  }
  hideLoading(){
    return wx.hideLoading()
  }

  showDialog(obj){
    return wx.showModal(obj)
  }

  showMenu(obj){
    return wx.showActionSheet(obj)
  }

  showKeyboard(obj){
    return wx.showKeyboard(obj)
  }

  getMenuBtnPos(){
    return wx.getMenuButtonBoundingClientRect()
  }
  setMenuBtnStyle(obj){
    return wx.setMenuStyle(obj)
  }
  setStatusBarStyle(obj){
    return wx.setStatusBarStyle(obj)
  }
  getSystemInfo(){
    return wx.getSystemInfoSync()
  }
}